package com.demo.zhou.sniper.module;


/**
 * 当颜色为红色时，前为大后为小，当颜色为蓝色的时候，后为大，前为小
 * Created by zhou on 2017/3/10.
 * 原始数
 */
public class Primitive {
    private int front;//前
    private int back;//后
    private int big;//大
    private int small;//小
    private int value;//值
    private boolean color;//颜色
    private boolean adengb;
    private boolean green;

    public Primitive(int value, boolean color, boolean green) {
        this.value = value;
        this.color = color;
        front = value / 10;
        back = value % 10;
        if ((value+"").length()==3){
            front=Integer.parseInt((value+"").substring(0,2));
            back=Integer.parseInt((value+"").substring(2,3));
        }else if ((value+"").length()==4){
            front=Integer.parseInt((value+"").substring(0,2));
            back=Integer.parseInt((value+"").substring(2,4));
        }
        adengb = front == back;
        if (color) {
            big = back;
            small = front;
        } else {
            big = front;
            small = back;
        }
        this.green = green;
    }

    public int getFront() {
        return front;
    }

    public int getBack() {
        return back;
    }

    public int getBig() {
        return big;
    }

    public int getSmall() {
        return small;
    }

    public int getValue() {
        return value;
    }

    public boolean isAdengb() {
        return adengb;
    }

    public boolean isColor() {
        return color;
    }

    private void parseInt(StringBuilder sb, int i) {
        switch (i) {
            case 0:
                sb.append("0");
                break;
            case 1:
                sb.append("1");
                break;
            case 2:
                sb.append("2");
                break;
            case 3:
                sb.append("3");
                break;
            case 4:
                sb.append("4");
                break;
            case 5:
                sb.append("5");
                break;
            case 6:
                sb.append("6");
                break;
            case 7:
                sb.append("7");
                break;
            case 8:
                sb.append("8");
                break;
            case 9:
                sb.append("9");
                break;
            case 10:
                sb.append("T");
                break;
            case 11:
                sb.append("J");
                break;
            case 12:
                sb.append("Q");
                break;
            case 13:
                sb.append("K");
                break;
        }
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        parseInt(sb, front);
        parseInt(sb, back);
        return sb.toString().intern();
    }

    public boolean isGreen() {
        return green;
    }

    public void setGreen(boolean green) {
        this.green = green;
    }
}